package com.l024.ljl.service;

import com.l024.ljl.dao.SysSubjectDao;
import com.l024.ljl.entity.PageEntity;
import com.l024.ljl.entity.SysSubjectEntity;
import com.l024.ljl.entity.SysUserEntity;
import com.l024.ljl.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 试题
 */
@Service
public class SysSubjectService implements BaseService<SysSubjectEntity>{
    @Autowired
    private SysSubjectDao sysSubjectDao;

    @Override
    public boolean add(SysSubjectEntity sysSubjectEntity) {
        return false;
    }

    @Override
    public boolean del(long id) {
        return false;
    }

    @Override
    public List<SysSubjectEntity> getAll() {
        Iterable<SysSubjectEntity> users = sysSubjectDao.findAll();
        List<SysSubjectEntity> list = new ArrayList<>();
        users.forEach(user->{list.add(user);});
        return list;
    }

    @Override
    public boolean update(SysSubjectEntity sysSubjectEntity) {
        return false;
    }

    @Override
    public PageEntity<SysSubjectEntity> page(int page, int size) {
        return null;
    }

    public List<SysSubjectEntity> getAllByTypeId(long typeId){
        if(typeId>0){
            return sysSubjectDao.findSysSubjectEntitiesByTypeId(typeId);
        }
        return null;
    }

    public  List<SysSubjectEntity> findSysSubjectEntitiesByTitle(String name){
        if(!StringUtil.isEmpty(name)){
           return sysSubjectDao.findSysSubjectEntitiesByTitle(name);
        }
        return null;
    }
}
